function [trainingPatterns testingPatterns] = parseSignal( dataset, window, overlapping )
    global one0Q;
    global one1Q;
    global one2Q;
    global one3Q;
    
    global one0QDiff;
    global one1QDiff;
    global one2QDiff;
    global one3QDiff;
    
    parsedInput = {};
    
    one0Pattern = {};
    o = 1;
    one1Pattern = {};
    p = 1;
    one2Pattern = {};
    q = 1;
    one3Pattern = {};
    r = 1;
    
    %z es el indice de testingPatterns
    z = 1;   
    
    j = 1;
    for i=1:(size(dataset,1)/(window-overlapping))-overlapping;
        parsedInput{i} = dataset(j:j+window-1,:);
        
        oneCounter = 0;
        consecutive = 0;
        for k=1:size(parsedInput{i},1)
            if parsedInput{i}(k,2) == 1
               consecutive = consecutive + 1;
            else
                if consecutive > oneCounter
                    oneCounter = consecutive;
                end
                consecutive = 0;
            end
            if consecutive > oneCounter
                oneCounter = consecutive;
            end
        end
        
        if oneCounter == 1 && p<=one1QDiff
            one1Pattern{p} = parsedInput{i};
            p = p + 1;
        elseif oneCounter == 2 && q<=one2QDiff
            one2Pattern{q} = parsedInput{i};
            q = q + 1;
        elseif oneCounter >= 3 && r<=one3QDiff
            one3Pattern{r} = parsedInput{i};
            r = r + 1;
        elseif oneCounter == 0 && o<=one0QDiff
            one0Pattern{o} = parsedInput{i};
            o = o + 1;
        else
            testingPatterns{z} = parsedInput{i};
            z = z + 1;
        end
        
        %testingPatterns{z} = parsedInput{i};
        %z = z + 1;
        
        j = j + window - overlapping;
    end
    
    k = 1;
    
    while k<one1Q
        for i=1:size(one1Pattern,2)
            trainingPatterns{k} = one1Pattern{i};
            k = k + 1;
        end
    end
    
    while k<one1Q+one2Q
        for i=1:size(one2Pattern,2)
            trainingPatterns{k} = one2Pattern{i};
            k = k + 1;
        end
    end
    
    while k<one1Q+one2Q+one3Q
        for i=1:size(one3Pattern,2)
            trainingPatterns{k} = one3Pattern{i};
            k = k + 1;
        end
    end
    
    while k<one1Q+one2Q+one3Q+one0Q
        for i=1:size(one0Pattern,2)
            trainingPatterns{k} = one0Pattern{i};
            k = k + 1;
        end
    end
end

